import json
import logging

from config import BASE_PATH


def build_data(filename, apiname):
    filepath = BASE_PATH + '/data' + filename + '.json'
    with open(filepath, 'r', encoding='utf-8') as f:
        json_data = json.load(f)
        api_date = json_data[apiname]
        # print(json_data)
        list_data = []
        for i in api_date:
            print(i)
            list_data.append(tuple(i.values()))

        print("获取的测试数据:{}".format(list_data))
        logging.info("获取的测试数据:{}".format(list_data))
        return list_data


if __name__ == '__main__':
    build_data('/reglogin', "img_verify_code")
    build_data('/reglogin', "get_phone_verify_code")
    build_data('/reglogin', "user_register")
    build_data('/reglogin', "user_login")
